package com.lc.demo.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lc.demo.bean.Goods;
import com.lc.demo.bean.User;
import com.lc.demo.result.ResponseMessage;
import com.lc.demo.service.GoodsService;
import com.lc.demo.util.JwtUtil;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: sakila
 * @Date: 2022/03/06/23:24
 * @Description:
 */
@RestController
@CrossOrigin
@RequestMapping("/api/index")
public class IndexController {

    @Autowired
    GoodsService goodsService;

    @GetMapping()
    public ResponseMessage login(Integer page, Integer sales, Integer newtime) {

        PageHelper.startPage(page, 10);
        List<Goods> goodsList = goodsService.selectGoodsList(sales, newtime);
        PageInfo<Goods> pageInfo = new PageInfo<>(goodsList);

        return ResponseMessage.successWithData(pageInfo);
    }
}
